#include "../../include/Reactor/TcpServer.h"


TcpServer::TcpServer(const string & ip, unsigned short port) 
: _acceptor(ip,port)
, _loop(_acceptor)
{

}

TcpServer::~TcpServer() {

}

void TcpServer::setAllCallback(callback && cb1, callback && cb2, callback && cb3, TimeCallback && cb4) {
    _loop.setNewConnectionCallback(std::move(cb1));
    _loop.setMessageCallback(std::move(cb2));
    _loop.setCloseCallback(std::move(cb3));
    _loop.setTimeCallback(std::move(cb4));
}

void TcpServer::start() {
    _acceptor.ready();
    _loop.loop();
}

void TcpServer::stop() {
    _loop.unloop();
}


